package com.hotel.controller;

import com.hotel.pojo.Bill;
import com.hotel.service.BillService;
import com.hotel.utils.ResultInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/Bill")
public class BillController {
    @Autowired
    private BillService billService;

    @RequestMapping("/billData")
    public ResultInfo billData() {
        List<Bill> bills = billService.selectAllBill();
        if (bills == null) {
            return new ResultInfo(200, "已获取数据", bills);
        }
        return new ResultInfo(500, "暂无数据", null);
    }

    @RequestMapping("/billVisual")
    public ResultInfo billVisual() {
        ResultInfo resultInfo = billService.billVisual();
        if (resultInfo == null) {
            return new ResultInfo(500, "没有可视化数据", null);
        }
        return new ResultInfo(200, "可视化数据", resultInfo);
    }

    @RequestMapping("/billInfoVisual")
    public ResultInfo billInfoVisual() {
        ResultInfo resultInfo = billService.billInfoVisual();
        return resultInfo;
    }

}
